package com.example.schoolenterprisealliance.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;

import com.example.schoolenterprisealliance.activity.DynamicActivity;
import com.example.schoolenterprisealliance.adapter.New_InformationAdapter;
import com.example.schoolenterprisealliance.bean.NewIfomation;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.example.schoolenterprisealliance.R;

import java.util.List;

public class CancelDialog extends Dialog {
    private int position;
    private List<NewIfomation.DataBean> data;
    private Context context;
    private New_InformationAdapter new_informationAdapter;
    private RecyclerView recyclerView;

    public CancelDialog(@NonNull Context context) {
        super(context);
    }
    public interface PriorityListener {
        /**
         * 回调函数，用于在Dialog的监听事件触发后刷新Activity的UI显示
         */
        void setActivityText(int position,String string);
    }
    private PriorityListener listener;
    public CancelDialog(@NonNull Context context, int themeResId,int position,PriorityListener listener) {
        super(context, themeResId);
        this.listener=listener;
        this.position=position;
    }
    protected CancelDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        TextView bt_confirm;
        TextView bt_cancel;
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.content_cancel_dialog);
        bt_confirm=findViewById(R.id.bt_confirm);
        bt_cancel=findViewById(R.id.bt_cancel);
           //通过另外一个布局对象的findViewById获取其中的控件
        bt_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                CancelDialog.this.dismiss();
            }
        });
        bt_confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                listener.setActivityText(position,"确认");
               CancelDialog.this.dismiss();

            }
                });
    }


}
